package com.baidu.utils;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 类描述
 *
 * @author Mr.Wu
 * @create 2020-10-19
 */
//@Controller
public class SendSms {



	/**
	 * 发送注册短信
	 * 注册流程： 填写表单数据+发短信+发邮件 》》3S .
	 */
	@RequestMapping("/sms/sendRegisterSms")
	public void sendLoginSms(@RequestParam("phone") String phone, @RequestParam("code") String code) {
		DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAIlzwM0t5b0i4r", "moYvfwB0g0xQLygciSMjXPYQDXapnj");
		IAcsClient client = new DefaultAcsClient(profile);
		CommonRequest request = new CommonRequest();
		request.setSysMethod(MethodType.POST);
		request.setSysDomain("dysmsapi.aliyuncs.com");
		request.setSysVersion("2017-05-25");
		request.setSysAction("SendSms");
		request.putQueryParameter("RegionId", "cn-hangzhou");
		request.putQueryParameter("PhoneNumbers", phone);
		request.putQueryParameter("SignName", "八维教育");
		request.putQueryParameter("TemplateCode", "SMS_138550047");
		request.putQueryParameter("TemplateParam", "{\"code\":"+code+"}");
		try {
			CommonResponse response = client.getCommonResponse(request);
			System.out.println(response.getData());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


}
